package cn.yj.core.business.controller;

import cn.yj.cgs.dba.entity.vo.PackagesView;
import cn.yj.admin.frame.AbstractController;
import cn.yj.syslog.common.LogType;
import cn.yj.syslog.common.OperateLog;
import cn.yj.core.business.service.PackageService;
import cn.yj.entity.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Map;

/**
 * @author 永健
 * @since 2021-06-09 15:16
 */
@RequestMapping("/packages")
@RestController
public class PackageController extends AbstractController<PackagesView> {

    @Resource
    private PackageService packageService;

    @Override
    @GetMapping("/pageList")
    @RequiresPermissions("packages:list")
    public R pageList(@RequestParam Map<String, Object> params) {
        return success(packageService.pageList(params, page()));
    }

    @OperateLog(describe = "删除快递代拿任务",type = LogType.DELETE)
    @DeleteMapping("/delete/{ids}")
    @RequiresPermissions("packages:del")
    public R deleteByNo(@PathVariable Integer[] ids) {
        return result(packageService.removeByIds(Arrays.asList(ids)));
    }


    /**
     * 更新审核状态
     *
     * @param body - status productNo
     */
    @PutMapping("/update/auditStatus")
    @RequiresPermissions("packages:update:status")
    @OperateLog(describe = "快递代拿任务审核",type = LogType.UPDATE)
    public R updateStatus(@RequestBody Map<String, Object> body) {
        return result(packageService.updateStatus(body));
    }
}
